0\rmq20(function () { 'use strict'; var _PUSH_EVENTS_UTM; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * Give the service worker access to Firebase Messaging. * Note that you can only use Firebase Messaging here, other Firebase libraries * are not available in the service worker. * **/ /* eslint-disable no-undef */ importScripts('https://www.gstatic.com/firebasejs/3.9.0/firebase-app.js'); importScripts('https://www.gstatic.com/firebasejs/3.9.0/firebase-messaging.js'); /** * Api url * * @type {string} */ var apiUrl = '/api/front/config'; /* eslint-enable no-undef */ /** * Push api events * * @type {enum} */ var PUSH_API_ICONS = { STRIPCHAT: '/worker/push_notification.png', XHAMSTERLIVE: '/worker/push_notification_xh.png' }; /** * Push events * * @type {enum} */ var PUSH_EVENTS = { PRIVATE_MESSAGE: 'privateMessage', MODEL_ONLINE: 'modelOnline' }; /** * Push events utm * * @type {enum} */ var PUSH_EVENTS_UTM = (_PUSH_EVENTS_UTM = {}, _defineProperty(_PUSH_EVENTS_UTM, PUSH_EVENTS.PRIVATE_MESSAGE, 'newMessagePush'), _defineProperty(_PUSH_EVENTS_UTM, PUSH_EVENTS.MODEL_ONLINE, 'modelOnlinePush'), _PUSH_EVENTS_UTM); /** * Is fetching config * * @type {?Boolean} */ var isFetching = void 0; /** * Config fetch promise * * @type {?Promise} */ var configPromise = void 0; /** * Static root * * @type {?string} */ var staticRoot = void 0; /** * Sender ID * * @type {string} */ var senderId = void 0; /** * Get action Url * * @param {string} event event name * @param {Object} data data * @return {string} */ var getActionUrl = function getActionUrl(event) { var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var _JSON$parse = JSON.parse(data), _JSON$parse$sender = _JSON$parse.sender, sender = _JSON$parse$sender === undefined ? '' : _JSON$parse$sender, _JSON$parse$modelUser = _JSON$parse.modelUsername, modelUsername = _JSON$parse$modelUser === undefined ? '' : _JSON$parse$modelUser; switch (event) { case PUSH_EVENTS.PRIVATE_MESSAGE: { return '/messages/' + sender; } case PUSH_EVENTS.MODEL_ONLINE: { return '/' + modelUsername; } default: { return ''; } } }; /** * Open client page * * @param {UIEvent} event */ var openClientPage = function openClientPage(event) { var _event$notification$d = event.notification.data, eventName = _event$notification$d.event, data = _event$notification$d.data; var eventUrl = getActionUrl(eventName, data); var utm = 'utm_campaign=push&utm_source=push&utm_medium=' + PUSH_EVENTS_UTM[eventName]; console.log('worker-push-notification openClientPage()', eventUrl); self.clients.openWindow(eventUrl + '?' + utm + '&pushNotification=' + eventName); event.notification.close(); }; // Firebase client var client = null; /** * Show notification * * @param {Object} payload */ var showNotification = function showNotification(payload) { console.log('worker-push-notification showNotification()', payload); var data = payload.data, _payload$data = payload.data, title = _payload$data.title, domain = _payload$data.domain, event = _payload$data.event, body = _payload$data.body; if (!event) { return null; } return self.clients.matchAll({ includeUncontrolled: true }).then(function (clientsList) { var hasActivePage = clientsList.length && clientsList.some(function (client) { return client.focused; }); console.log('worker-push-notification showNotification() is active page', hasActivePage); if (!hasActivePage) { // Customize notification here var notificationTitle = title; var notificationOptions = { icon: staticRoot + '/..' + (domain ? PUSH_API_ICONS.XHAMSTERLIVE : PUSH_API_ICONS.STRIPCHAT), data: data, body: body }; return self.registration.showNotification(notificationTitle, notificationOptions); } return null; }); }; /** * Initialize firebase app */ var initializeApp = function initializeApp() { if (client) { return; } /** * Initialize the Firebase app in the service worker by passing in the messagingSenderId. */ client = firebase.initializeApp({ messagingSenderId: senderId }); /** * Retrieve an instance of Firebase Messaging so that it can handle background messages. */ var messaging = firebase.messaging(); /** * Set background message handler */ messaging.setBackgroundMessageHandler(function (payload) { console.log('worker-push-notification setBackgroundMessageHandler', payload); return showNotification(payload); }); }; /** * Update config */ var updateConfig = function updateConfig() { if (!isFetching) { isFetching = true; configPromise = fetch(apiUrl).then(function (data) { return data.json(); }).then(function (data) { var config = data.config; console.log('worker-push-notification fetch config', data); staticRoot = config.staticRoot; senderId = config.fcm.senderId; isFetching = false; initializeApp(); }); } return configPromise; }; /** * Add event listener activate */ self.addEventListener('activate', function (event) { console.log('worker-push-notification activate()', event); if (!client) { event.waitUntil(updateConfig()); } }); /** * Add event listener push */ self.addEventListener('push', function (event) { var data = event.data.json(); console.log('worker-push-notification push()', event, data); var promise = new Promise(function (resolve) { if (!client) { return updateConfig().then(function () { return showNotification(data); }).then(function () { return resolve(); }); } return resolve(); }); event.waitUntil(promise); }); /** * Add event listener notification click * Call if click on notification */ self.addEventListener('notificationclick', function (event) { console.log('worker-push-notification notificationclick()', event); event.waitUntil(openClientPage(event)); }); updateConfig(); }()); A EooW@J^A. K^A.HTTP/1.1 200status:200server:nginxdate:Mon, 05 Mar 2018 14:24:33 GMTcontent-type:application/javascript; charset=utf-8last-modified:Wed, 28 Feb 2018 15:35:58 GMTvary:Accept-Encodingetag:W/"5a96cc5e-18d5"x-frame-options:denycontent-encoding:gzip00 m۶HoBU705031/-http://cdp.rapidssl.com/RapidSSLRSACA2018.crl0LU E0C07 `Hl0*0(+https://www.digicert.com/CPS0g 0u+i0g0&+0http://status.rapidssl.com0=+01http://cacerts.rapidssl.com/RapidSSLRSACA2018.crt0 U00 +yv߼q#{G8W Rd6хapi"G0E!XNٔF^XQl0Fe_@Ѩ~+ Gq<@:ES&) {]XWvuY|C_nVGV6J`^api"G0E!nXSN.h (o YChՎ捊T`NsJF`6]<>0  *H  lfiX6z [wbwf}>~dāH8/Br|Gg '>sVX7Lćfڮ9ŭ͞>XAE.xM n$ҙ6\voȧc>8>B aܦP] 8,oYb%3WIֳ$KVHU4@!uF=)wǸ(00FK\SI0  *H  0a1 0 UUS10U  DigiCert Inc10U www.digicert.com1 0UDigiCert Global Root CA0 171106122333Z 271106122333Z0^1 0 UUS10U  DigiCert Inc10U www.digicert.com10URapidSSL RSA CA 20180"0  *H 0 -(y{:3;qe,)e-FNgVwW=| .|ZySE!Q< 9NXL6mnT*[e%k_'BqQ4(~piȜ* 0\'D[A1K.,pfB{TU f I`OrI"evg7{xk潃 ̎m0ck$OץkV鸤(9B;uzp!Lpy$uf0b0USYk!/䪨Vu0U#0P5VLf×=U0U0U%0++0U004+(0&0$+0http://ocsp.digicert.com0BU;0907531http://crl3.digicert.com/DigiCertGlobalRootCA.crl0cU \0Z07 `Hl0*0(+https://www.digicert.com/CPS0  `Hl0g 0g 0  *H  ~#5nYQ\ak<6|)Bأa++%ZnR̪ߑl'^cKYuHdG?$N(pL]dEۚ'TqzH':Ie\('R(ٶ)0RͭXN}%J9##TGWA#_")'eCCΏ:BAbrH }klpXz7lZQ/SwBj>^M\j00;VBFujYJ0  *H 0a1 0 UUS10U  DigiCert Inc10U www.digicert.com1 0UDigiCert Global Root CA0 061110000000Z 311110000000Z0a1 0 UUS10U  DigiCert Inc10U www.digicert.com1 0UDigiCert Global Root CA0"0  *H 0 ;rިӣWP wɢΖ[ N0SCiW"݇@ ;qFfv'{}H֯z 9eJ](tzxYhn\#2KNZmpw٨DX2uѢG'j3I`_:JL}>O_lv^K7"mjͳd[)2 BԫA2 ջX?I(p1L NJ=^ï'c0a0U0U00UP5VLf×=U0U#0P5VLf×=U0  *H ˜7H DOR߮yy$K+-X˸mzt)pLpc`ӣ[ ՎSc?۴fbfnA-wJX+Y@#-(E>yT&H7y`ެnD8/IE>*6S:P.WIla!x<,:k؉8lldw%W0$G|$0- EPȈƘ4_ <Օm0P ߼q#{G8W Rd6хp5c5.G0E!XNٔF^XQl0Fe_@Ѩ~+ Gq<@:ES&) {]XWGoogle 'Skydiver' log uY|C_nVGV6J`^@5c5.G0E!nXSN.h (o YChՎ捊T`NsJF`6]<>DigiCert Log Server 2p j4@$ u 88.208.29.18h28H&/ud3x-= +A Eo%=